<?php

namespace App\Http\Controllers;

use App\Http\BizServices\ReportBizService;
use App\Http\Request\ClickRequest;
use App\Http\Request\DownloadRequest;
use App\Http\Request\ExposureRequest;
use App\Http\Rules\Auth\AuthValidate;

class ReportController extends BaseController
{
    public function __construct(AuthValidate $validate)
    {
        $this->validate = $validate;
    }

    /**
     * 曝光上报
     * @return \Illuminate\Http\JsonResponse
     */
    public function exposure()
    {
        $data = $this->checkParam('');
        if (isset($data['code'])) {
            return $this->jsonResponse('101', $data['message']);
        }
        $reportBizService = new ReportBizService();
        $exposure         = $reportBizService->exposure(new ExposureRequest($data));
        return self::jsonResponse('0', '上报成功', $exposure);
    }

    public function click()
    {
        $data = $this->checkParam('');
        if (isset($data['code'])) {
            return $this->jsonResponse('101', $data['message']);
        }
        $reportBizService = new ReportBizService();
        $click         = $reportBizService->click(new ClickRequest($data));
        return self::jsonResponse('0', '上报成功',$click);
    }

    public function download()
    {
        $data = $this->checkParam('');
        if (isset($data['code'])) {
            return $this->jsonResponse('101', $data['message']);
        }
        $reportBizService = new ReportBizService();
        $download         = $reportBizService->download(new DownloadRequest($data));
        return self::jsonResponse('0', '上报成功', $download);
    }
}
